<script>
    img=true;
     var img_sh = "<%=image_path("restaurant.shadow.png")%>";
     var img_p =  "<%=image_path("restaurant.png")%>";
</script>
<div id="left"></div>
<div id="right">
<% if (session[:role] == "admin") %>
<h1>Listing restaurants</h1>

<table class="three" cellspacing="0">
  <tr>
    <th>Rest name</th>
    <th>Rest province</th>
    <th>Rest detail</th>
    <th>Rest lat</th>
    <th>Rest long</th>
    <th>Rest img</th>
    <th>Rest rate</th>
  </tr>

<% @restaurants.each do |restaurant| %>
  <tr>
    <td><%=h restaurant.rest_name %></td>
    <td><%=h restaurant.rest_province %></td>
    <td><%=h restaurant.rest_detail %></td>
    <td><%=h restaurant.rest_lat %></td>
    <td><%=h restaurant.rest_long %></td>
    <td><%=h restaurant.rest_img %></td>
    <td><%= link_to 'Show', restaurant %></td>
    <td><%= link_to 'Edit', edit_restaurant_path(restaurant) %></td>
    <td><%= link_to 'Destroy', restaurant, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>
<% elsif session[:user] %>
<h2>ที่กิน</h2>
<ul>
 <% for restaurant in @restaurants %>
  <li>
    <%= link_to restaurant.rest_province,
      :action => "show",
      :id => restaurant %>
  </li>
<% end %></ul>
<br />

<%= link_to 'เพิ่มจังหวัดที่กิน', new_restaurant_path %>
<% else %>
<p>สมัครสมาชิกเพื่อใช้งาน ... </p>
<% end %>
</div>